<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>

<!DOCTYPE html>
<html>
<head>
<title>查看合同</title>
<meta name="decorator" content="default" />
<style type="text/css">
.input.normal {
	width: 200px !important;
}
</style>
<script type="text/javascript">
	$(function() {
		//上传控件
		$(".upload-app").InitUploader({ type:'contract', filesize: "", sendurl: "${ctx}/qd/upload", swf: "${ctxStatic}/scripts/webuploader/uploader.swf", filetypes: "*" });
		//初始化表单验证
		$("#inputForm").initValidform();
	});
	
	function addImage(parentObj, data){
		if(data.type=='contract'){
			$('#attachUrl').val(data.path);
		}
	}
	/* function getBrokenById(contractid){
		var broken = null;
		$.post("${ctx}/qd/contract/getbroken?method=getbrokenbyid", {
			"contractid" : contractid
		}, function(result) {
			if (result != "") {
				$("#broken").val(result);
				broken = result;
			}
		}, "text");
		return broken;
	} */

	/* function getMemberId() {
		var memberMobile = $("#memberMobile").val();
		var memberName = $("#memberName").val();
		$.post("${ctx}/qd/contract/ajax?method=getmemberid", {
			"memberMobile" : memberMobile,
			"memberName" : memberName
		}, function(result) {
			if (result != "") {
				$("#memberId").html(result);
				$('.rule-single-select').ruleSingleSelect();
			}
		}, "text"); */

		/*var studentName = $("#studentName").val();
		$.post("${ctx}/qd/contract/ajax?method=getstudentid", {
			"studentName" : studentName,
			"memberMobile" : memberMobile
		}, function(result) {
			if (result != "") {
				$("#studentId").html(result);
				$('.rule-single-select').ruleSingleSelect();
			}
		}, "text");*/
	//}

	/* function getStudentId() {
		var studentName = $("#studentName").val();
		$.post("${ctx}/qd/contract/ajax?method=getstudentid", {
			"studentName" : studentName,
		}, function(result) {
			if (result != "") {
				$("#studentId").html(result);
				$('.rule-single-select').ruleSingleSelect();
			}
		}, "text");
	} */

	/* function add(){
		if(top){
			var width = $(top.window).width()-100,height=$(top.window).height()-100;
			var memberId = "";
			var studentId = "";
			var contractId = "";
			if('${contract.id}' != null){
				memberId = '${contract.member.id}';
				studentId = '${contract.student.id}';
				contractId = '${contract.id}';
			}
			
			top.dialog({
				title:'添加收支记录',
				url:'${ctx}/qd/contract/dialog?contractId='+contractId+'&memberId='+memberId+'&studentId='+studentId,
				width:width, 
				height:height
			}).showModal();
		} 
	} */
</script>
<style type="text/css">
	.prom{
		width:80%;
		border: 0.5px solid #ccc;
		float:left;
		font-size: 13px;
	}
</style>
</head>

<body class="mainbody">
	<form:form id="inputForm" modelAttribute="contract" action="${ctx}/qd/contract/save" method="post" class="form-horizontal">
		<form:hidden id="contractid" path="id" />
		<sys:message content="${message}" />

		<!--导航栏-->
		<div class="location">
			<a href="${ctx}/qd/contract/list" class="back"><i></i><span>返回列表页</span></a>
			<a href="${ctx}/center" class="home"><i></i><span>首页</span></a> <i
				class="arrow"></i> <a href="${ctx}/qd/contract/"><span>合同管理</span></a>
			<shiro:hasPermission name="qd:contract:edit">
				<i class="arrow"></i>
				<span>${not empty contract.id ? '修改':'添加' }合同</span>
			</shiro:hasPermission>
		</div>
		<div class="line10"></div>
		<!--/导航栏-->

		<!--内容-->
		<div id="floatHead" class="content-tab-wrap">
			<div class="content-tab">
				<div class="content-tab-ul-wrap">
					<ul>
						<li><a class="selected" href="javascript:;">合同信息</a></li>
					</ul>
				</div>
			</div>
		</div>

		<div class="tab-content" style="font-size: 14px;">
			<div style="width: 100%">
			<div style="float: left; width: 30%;	">
					<dl>
						<dt>合同ID:</dt>
						<dd>
							${contract.id }
						</dd>
					</dl>
				</div>
				<div style="float: left; width: 30%;	">
					<dl>
						<dt>合同编号:</dt>
						<dd>
							${contract.code }
						</dd>
					</dl>
				</div>
				<div style="float: left; width:30%;">
					<dl>
						<dt>所属顾问:</dt>
						<dd>
								${contract.sales.name }
						</dd>
					</dl>
				</div>
			</div>
			<div style="width: 100%">
				<div style="float: left; width: 30%;">
					<dl>
						<dt>合同金额:</dt>
						<dd>
						${contract.amount }
						</dd>
					</dl>
				</div>
				<div style="float: left; width: 30%;">
					<dl>
						<dt>合同余额:</dt>
						<dd>
						<c:choose><c:when test="${balance == null }">该合同已停止使用</c:when><c:otherwise>${balance}</c:otherwise></c:choose>
						</dd>
					</dl>
				</div>
				<div style="float: left; width: 30%;">
					<dl>
						<dt>冻结金额:</dt>
						<dd>
						<c:choose><c:when test="${balance == null }">该合同已停止使用</c:when><c:otherwise>${frozenBalance}</c:otherwise></c:choose>
						</dd>
					</dl>
				</div>
			</div>
			<div style="width: 100%">
				<div style="float: left; width:30%;">
					<dl>
						<dt>会员真实姓名:</dt>
						<dd>
						${contract.member.name }
						</dd>
					</dl>
				</div>
				<div style="float: left; width: 30%;">
					<dl>
						<dt>会员手机号:</dt>
						<dd>
							${contract.member.mobile }
						</dd>
					</dl>
				</div>
			</div>
			<div style="width: 100%">
				<div style="float: left; width: 30%;">
					<dl>
						<dt>宝宝姓名:</dt>
						<dd>
							${contract.student.name }
						</dd>
					</dl>
				</div>
				<div style="float: left; width:30%;">
					<dl>
						<dt>宝宝出生日期:</dt>
						<dd>
						<fmt:formatDate value="${contract.student.birthday}"
									pattern="yyyy-MM-dd"  />
						</dd>
					</dl>
				</div>
			</div>
			<div style="width: 100%">
				<div style="float: left; width: 30%;">
					<dl>
						<dt>宝宝性别:</dt>
						<dd>
							<c:choose><c:when test="${contract.student.sex == '0' }">男</c:when><c:when test="${contract.student.sex == '1' }">女</c:when><c:otherwise>未知</c:otherwise></c:choose>
						</dd>
					</dl>
				</div>
				<div style="float: left; width: 30%;">
					<dl>
						<dt>合同状态:</dt>
						<dd>
						<c:choose><c:when test="${contract.abort == '0' }">正常</c:when><c:when test="${contract.abort == '1' }">中止</c:when></c:choose>
						</dd>
					</dl>
				</div>
			</div>
			<div style="width: 100%">
				<div style="float: left; width: 30%;">
					<dl>
						<dt>合同签订日期:</dt>
						<dd>
							<fmt:formatDate value="${contract.signDate}"
									pattern="yyyy-MM-dd" />
						</dd>
					</dl>
				</div>
				<div style="float: left; width: 30%;">
					<dl>
						<dt>有效期至:</dt>
						<dd>
								<fmt:formatDate value="${contract.limitDate}" pattern="yyyy-MM-dd" />
						</dd>
					</dl>
				</div>
				<div style="float: left; width: 30%;">
					<dl>
						<dt>请假返款次数:</dt>
						<dd>
							${contract.leavePriv.total - contract.leavePriv.used}
							<c:if test="${contract.leavePriv.total == null}">0</c:if>
						</dd>
					</dl>
				</div>
				<%-- <div style="float: left; width: 50%;">
					<dl>
						<dt>中止返款次数</dt>
						<dd>
						<form:hidden path="abortPriv.id"/>
							<form:input path="abortPriv.total" htmlEscape="false" maxlength="50"
								class="required" cssClass="input small" datatype="/\d+/" nullmsg="请输入中止返款次数" errormsg="中止返款次数输入有误" sucmsg=" " />
						</dd>
					</dl>
				</div> --%>
				<div id="brokenDiv"  style="float: left; width: 30%;">
					<dl>
						<dt id="brokenLabel">是否断号:</dt>
						<dd>
							<c:choose><c:when test="${contract.broken == 0 }">未断号</c:when><c:when test="${contract.broken == 1 }"><p style="color: red">断号</p></c:when><c:otherwise>查询异常</c:otherwise></c:choose>
						</dd>
					</dl>
				</div>
				<div id="brokenReasonDiv" style="float: left; width: 30%;">
					<dl>
						<dt>断号理由:</dt>
						<dd>
						${contract.brokenReason }
						</dd>
					</dl>
				</div>
			 	 <dl>
					<dt>附件:</dt>
					<dd>
					<div class="table-container">
						<table class="border-table" style="text-align: center" id= "attachtable">
							<thead>
								<tr>
								<th>文件名</th>
								<th>操作</th>
								</tr>
								</thead>
								<tbody >
								<c:forEach items="${contractAttach}" var="attach">
									<tr>
										<input type="hidden" name="hid_attach_name" value="${attach.category }|${attach.fileName }|${attach.filePath }|${attach.fileSize }">
										<input type="hidden" name="hid_attach_remark" value="${attach.fileName  }">
										<td>${attach.fileName }</td>
										<td><a href="${ctx }/../download/downloadfile?filepath=upload/${attach.filePath }&filename=${ attach.fileName}">下载</a></td>
			                   		</tr>
								</c:forEach>
								</tbody>
							</table>
						</div>
						<%-- <div class="photo-list">
						<ul>
						<c:if test="${contractAttach == null}">无</c:if>
							<c:forEach items="${contractAttach }" var="attach">
								<li>
								<input type="hidden" name="hid_attach_name" value="${attach.category }|${attach.fileName }|${attach.filePath }|${attach.fileSize }">
	                        		<input type="hidden" name="hid_attach_remark" value="${attach.fileName  }">
	                        		<div class="img-box"  onclick="setFocusImg(this);">
	                        			<img src="${ctxStatic}/images/icon_attch.png"  width="400px" height="400px">
	                        			<span class="remark"><i>${ attach.fileName}</i></span>
	                        		</div>
	                        		<a href="javascript:;" onclick="setRemark(this);">描述(命名)</a>
	                        		<a href="${ctx}/../../upload${attach.filePath }" >下载</a>
							</c:forEach>
						</ul>
						</div> --%>
					</dd>
				</dl>
				<dl >
					<dt>免费体验:</dt>
					<dd>
					   <c:choose><c:when test="${contract.isFree == '0' }">否</c:when><c:when test="${contract.isFree == '1' }">是</c:when></c:choose>
					</dd>				
				</dl>
				<dl>
				<dt>优惠信息:</dt>
					<dd>
							<div class="prom">
								<c:forEach items="${proms}" var="prom">
									${prom }<br>
								</c:forEach>
							</div>
					</dd>
				</dl>
				
			</div>
			<!--列表-->
			<br />
			<br />
			<br />
			<dl style="float: left">
				<dt>支付记录</dt>
			</dl>
			<br />
			<br />
			<br />
			<%--   <div class="btn-wrap">
					<input type="button"  onclick="add();"  value="新增" class="btn" /> 
					</div>
					<br/>  --%>
			<div class="table-container" style="padding-left: 30px;font-size: 12px;">
				<table class="border-table" style="text-align: center">
					<thead>
						<tr>
							<th width="100">交易金额</th>
							<th width="100">支付方式</th>
							<th width="100">支付单号</th>
							<th width="100">发生日期</th>
							<th width="100">描述</th>
							<th width="100">状态</th>
							<th width="100">创建人</th>
							<th width="100">作废人</th>
							<th width="100">作废理由</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${page.list}" var="transrecord">
							<tr>
								<td>${transrecord.money}</td>
								<td><c:choose>
										<c:when test="${transrecord.payType==0}">pos机刷卡</c:when>
										<c:when test="${transrecord.payType==1}">微信支付</c:when>
										<c:when test="${transrecord.payType==2}">支付宝支付</c:when>
										<c:when test="${transrecord.payType==3}">银联在线支付</c:when>
										<c:when test="${transrecord.payType==4}">系统返还</c:when>
										<c:when test="${transrecord.payType==6}">现金支付</c:when>
										<c:otherwise>系统扣费</c:otherwise>
									</c:choose></td>
								<td>${transrecord.payCode}</td>
								<td><fmt:formatDate value="${transrecord.payDate}"
										pattern="yyyy-MM-dd" /></td>
								<td>${transrecord.description }</td>
								<td><c:choose>
										<c:when test="${transrecord.invalid==0}">生效</c:when>
										<c:otherwise>作废</c:otherwise>
									</c:choose></td>
								<td>${transrecord.createBy.name}</td>
								<td>${transrecord.invalidBy}</td>
								<td>${transrecord.invalidReason}</td>
							</tr>
						</c:forEach>
					</tbody>
				</table>
			</div>
			<!--/列表-->
		</div>
		<!--/内容-->

		<!--工具栏-->
		<div class="page-footer">
			<div class="btn-wrap">
				 <input name="btnReturn" type="button" value="返回上一页"
					class="btn" onclick="javascript:history.back(-1);" />
			</div>
		</div>
		<!--/工具栏-->
	</form:form>
</body>
</html>

